<?php
		global $wpdb;
		$date = $date = date('Y-m-d H:s:i');
		$customer = array(
 			'customerName'			=> stripslashes($_POST['Name']),
 			'customerEmail'			=> stripslashes($_POST['Email']),
 			'customerAddress'		=> stripslashes($_POST['Address']),
 			'customerPhone'			=> stripslashes($_POST['Tel']),
 			'customerFax'			=> ' ',
 			'customerComment'		=> stripslashes($_POST['Message']),			
			'guestParent'			=> 0,
 			'date'					=> $date	
 			);
 		$customerID = db_insert_data("customers",$customer,$date);
 		
 		//print_r($_POST); 	
 		##process guest	
 		for ($i=1;$i<=5;$i++)
 		{
 			$guests_name = $_POST['fullname'.$i];
 			$guests_pass = $_POST['passport'.$i];
 			if($guests_name != null && $guests_pass != null)
 			{ 
	 			$guest_expiration= $_POST['update_INyr'.$i].'-'.$_POST['update_INmo'.$i].'-'.$_POST['update_INdy'.$i].' 00:00:00';
	 			
	 			$guests = array(
		 			'customerName'			=> stripslashes($guests_name),
		 			'customerEmail'			=> '',
		 			'customerAddress'		=> '',
		 			'customerPhone'			=> '',
		 			'customerFax'			=> '',
		 			'customerComment'		=> '', 				
					'guestParent'			=> $customerID,
		 			'date'					=> $date	
	 			);
	 			$guestID = db_insert_data("customers",$guests,$date);
	 			$passports = array(
	 				'customerID' 		=> $guestID,
	 				'passportNumber'	=> $guests_pass,
	 				'expiration'		=> $guest_expiration,
	 				'date'				=> $date
	 			);
	 			$passportID = db_insert_data("passports",$passports,$date);
 			}
 		}
 		
 		## process payment
 							$payments = $_POST['hidden_payment'];
 							if(!$payments || $payments=="")
 								$payments = 'Pay in cash';
 							$payment = array(
 							'price'			=> $_POST['hidden_visa_price'],
 							'deposit'		=> $_POST['hidden_visa_deposit'],
 							'paymentMethod'	=> $payments,
 							'paymentCurrent'	=>$_POST['hidden_payment_curent'],
 							'paymentStatus' => 'Pending',
 							'date'	=> $date	
 							);
 		$paymentID  = db_insert_data("payments",$payment,$date); 					
 		
 		## Process Visa
 		$number_of_visa = $_POST['numberVisa'];
 		$type_of_visa = $_POST['typeVisa'];
 		$purpose  = $_POST['purpose'];
 		$precessingtime = $_POST['precessingtime'];
 		
 		$arrival_date 	= $_POST['yrArrival'].'-'.$_POST['moArrival'].'-'.$_POST['dyArrival'].' 00:00:00';
 		$exit_date 		= $_POST['yrExit'].'-'.$_POST['moExit'].'-'.$_POST['dyExit'].' 00:00:00';
 		
 		$arrivalAirport  = $_POST['arrivalAirport'];
 		$flightnumber    = $_POST['flightnumber'];
 		
 		$visas = array(
 			'numberVisa' 		=> $number_of_visa,
			'typeVisa' 			=> $type_of_visa,
			'purposeVisa' 		=> $purpose,
			'processingTime' 	=> $precessingtime,
			'dateArrival' 		=> $arrival_date,
			'dateExit'			=> $exit_date,
			'arrivalAirport'	=> $arrivalAirport,
			'flightNumber'		=> $flightnumber,
			'customerID'		=> $customerID,		
 			'paymentID'			=> $paymentID,	
 			'date'				=> $date
 		);
 		$visasID = db_insert_data("visas",$visas,$date);
 		$email_support = "email_support_visa";
 		$_SESSION['ma_xac_nhan'] = null;
 		